package test.fra;

import java.util.ArrayList;
import java.util.List;

/**
 * 模型
 * 
 * @author fujinjun
 * 
 */
public class Model {
	public String name;
	public List<String> fields;

	public Model() {
		fields = new ArrayList<String>();
	}

	@Override
	public String toString() {
		return name + "[" + ArrayUtil.join(fields.toArray(), ",") + "]";
	}

	/**
	 * 将字符串转化为model对象
	 * 
	 * @param str
	 * @return
	 */
	public static Model from(String str) {
		Model model = new Model();
		String[] split = str.split("\\n");
		model.name = split[0].trim();
		for (int i = 1; i < split.length; i++) {
			if (StringUtil.replaceBlank(split[i]).isEmpty()) {
				continue;
			}
			model.fields.add(split[i].trim());
		}
		return model;
	}

}
